package com.runvp.common.enums;

/**
 * 客户账户类型(main:主账户,unit:测试账户)
 *
 */
public enum AccountType implements BaseEnumInterface{
    MAIN("main", "主账户"),
    UNIT("unit", "测试账户");
    private String code;    //类型
    private String desc;    //描述
    private String defaulted;

    private AccountType(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    AccountType(String code, String desc, String defaulted) {
        this.code = code;
        this.desc = desc;
        this.defaulted = defaulted;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDesc() {
        return desc;
    }

    @Override
    public String getDefaulted() {
        return defaulted;
    }

    /**
     * 是否包含枚举key值
     *
     * @param key
     * @return boolean true：包含，  false：不包含
     */
    public static boolean isContains(String key) {
        if(null == key || "".equals(key)){return  false ;}
        for (AccountType e: AccountType.values()){
            if(key.equals(e.getCode())){
                return true;
            }
        }
        return false;
    }

    /**
     * 根据key获取对应value
     * @param key
     * @return str
     */
    public static String getValue(String key) {
        if(null == key || "".equals(key)){return  "未知" ;}
        for (AccountType e: AccountType.values()){
            if(key.equals(e.getCode())){
                return e.getDesc();
            }
        }
        return "未知";
    }
}
